/*
 * @Date: 2023-02-21 20:20:29
 * @LastEditTime: 2023-03-04 21:11:39
 * @FilePath: /hash-guess-game/src/api/module/bonusList.ts
 * 介绍:
 */
import { defaHttp, Paging, ApiReturn } from "../index";

/**分红列表 */
export async function apiBonusList(
  formData: Paging.Req
): ApiReturn<Paging.Data<BonusList.ResItem[]>> {
  const res = await defaHttp.post<Paging.Res<BonusList.ResItem[]>>(
    "/money/share",
    formData,
    { mode: ["showError"] }
  );

  if (res.code !== 200) return;
  return res.data;
}
/**分红列表 */
export namespace BonusList {
  export interface ResItem {
    id: Id;
    address: string;
    created_at: string | Date;
    number: StrNumber;
    coin: Coin;
  }
}

/**赛时分红 */
export async function apiGameTimeBonusList(
  formData: Paging.Req
): ApiReturn<Paging.Data<GameTimeBonusList.ResItem[]>> {
  const res = await defaHttp.post<Paging.Res<GameTimeBonusList.ResItem[]>>(
    "/buy/share/rewardlog",
    formData,
    { mode: ["showError"] }
  );

  if (res.code !== 200) return;
  return res.data;
}
/**赛时分红 */
export namespace GameTimeBonusList {
  export interface ResItem {
    id: Id;
    address: string;
    created_at: string | Date;
    number: StrNumber;
    coin: Coin;
  }
}

/**赛车分红 */
export async function apiGameVehicleBonusList(
  formData: Paging.Req
): ApiReturn<Paging.Data<GameVehicleBonusList.ResItem[]>> {
  const res = await defaHttp.post<Paging.Res<GameVehicleBonusList.ResItem[]>>(
    "/car/reward/logs",
    formData,
    { mode: ["showError"] }
  );
  if (res.code !== 200) return;
  res.data.data = res.data.data.map((v: AnyObj) => ({
    number: v.money,
    ...v,
  })) as any;
  return res.data;
}
/**赛车分红 */
export namespace GameVehicleBonusList {
  export interface ResItem {
    id: Id;
    address: string;
    created_at: string | Date;
    number: StrNumber;
    coin: Coin;
  }
}
